﻿using D.Medicalcare.Domain.Entities;
using D.Medicalcare.ErrorCode;
using D.Medicalcare.Read.API.Application.Command.RegistrationCommand;
using D.Medicalcare.Read.API.Dtos;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace D.Medicalcare.Read.API.Controllers
{
    /// <summary>
    /// 挂号管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RegistrationController : ControllerBase
    {
        private readonly IMediator mediator;

        public RegistrationController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取一条挂号信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<RegistrationDTO>> QueryRegistration([FromQuery]QueryRegistrationCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 获取预约挂号信息分页
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIPaging<RegistrationDTO>> GetRegistration([FromQuery]GetRegistrationCommand request)
        {
            return mediator.Send(request);

        }
        /// <summary>
        /// 就诊信息获取
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<GetNoRegistrationDto>> GetNoRegistration([FromQuery]GetNoRegistrationCommand request)
        {
            try
            {
                return mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 获取医院科室信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<Department>>> GetDepartmentId([FromQuery]GetDepartmentIdCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 获取就诊人挂号信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<RegistrationDTO>>> GetRegistrationPatients([FromQuery]GetRegistrationPatientsCommand request)
        {
            return  mediator.Send(request);
        }
        /// <summary>
        /// 医生排班
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<PdoctorDto>>> GetPdoctor([FromQuery] GetPdoctorCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改排班数
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<object>> UpdateDockorNum([FromQuery]UpdateDockorNumCommand request)
        {
            return mediator.Send(request);
        }
    }
}
